package com.lsf.dunlian.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;

import com.google.gson.Gson;
import com.lsf.dunlian.R;
import com.lsf.dunlian.adapter.MemberHandlerRecyclerViewAdapter;
import com.lsf.dunlian.databinding.ActivityMemberhanlerBinding;
import com.lsf.dunlian.entity.BasicMember;
import com.lsf.dunlian.entity.MemberHandlerEntity;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MemberHanlerActivity extends Activity {

    private ActivityMemberhanlerBinding binding;
    private MemberHandlerRecyclerViewAdapter adapter;

    private List<MemberHandlerEntity> list = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        BaseUtils.setStatusBar(this);
        binding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_memberhanler, null, false);
        setContentView(binding.getRoot());

        String data = getIntent().getStringExtra("data");
        BasicMember member = new Gson().fromJson(data, BasicMember.class);
        binding.address.setText(member.getAddress());
        binding.project.setText(member.getName());
        binding.shoujihao.setText(member.getLianxirenDianhua());
        binding.back.setOnClickListener(v -> finish());

        list.add(new MemberHandlerEntity(R.drawable.jibenxinxi,"基本信息",1));
        list.add(new MemberHandlerEntity(R.drawable.genjinjilu,"跟进记录",2));
        list.add(new MemberHandlerEntity(R.drawable.jieduangongzuo,"阶段工作",3));
        list.add(new MemberHandlerEntity(R.drawable.kaipiaoxinxi,"开票信息",4));

        adapter= new MemberHandlerRecyclerViewAdapter(list,this,data);
        binding.recyclerView.setAdapter(adapter);
        binding.recyclerView.setLayoutManager(new GridLayoutManager(this,4));
    }
}
